﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LIMS.Web
{
    public partial class AdminLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ibtnSubmit_Click(object sender,EventArgs e)
        {
            #region 假如浏览器禁用Cookies，则提示用户开启Cookies
            if (Request.Cookies["ValidateCode"] == null)
            {
                string strMessage = string.Format("alert('您的浏览器设置已禁用Cookies，您必须启用浏览器的Cookies选项后才能使用本系统!')");
                this.ClientScript.RegisterStartupScript(this.GetType(), "", strMessage, true);
                return;
            }
            #endregion

            if (string.Compare(Request.Cookies["ValidateCode"].Value, txtValidate.Value.Trim()) != 0)
            {
                lblError.InnerText = "验证码错误";
                return;
            }


           Boolean isLogin = BLL.LoginManager.AdminLogin(new Model.Admins() { adminID = txtAdminID.Value.Trim(), adminPwd = txtPwd.Value.Trim() });
           if (!isLogin)
           {
               lblError.InnerText = "用户名或密码错误";
               return;
           }
           Session["adminID"] = txtAdminID.Value.Trim();
           Response.Redirect("Admindex.html");
        }
    }
}